package cn.xianshu.service.impl;

import cn.xianshu.constants.BaseConstants;
import cn.xianshu.domain.Meal;
import cn.xianshu.mapper.MealMapper;
import cn.xianshu.service.IMealService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 套餐表 服务实现类
 * </p>
 *
 * @author Uncle Xian
 * @since 2021-11-22
 */
@Service
public class MealServiceImpl extends ServiceImpl<MealMapper, Meal> implements IMealService {
    @Autowired
    private MealMapper mealMapper;


    @Override
    public void saveRelaationWithLogin(Long mealId, Long loginId) {

        Date expireTime = DateUtils.addDays(new Date(), 7);

        mealMapper.saveRelaationWithLogin(mealId, // 套餐id
                loginId, // 机构管理员的loginid
                expireTime, // 试用时间
                BaseConstants.Meal.STATE_UN_PAY); // 状态未支付
    }
}
